package com.cmc.cloud.cmclink.doc.controller.admin.special;

import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.vo.specialcargomaximumvo.SpecialCargoMaximumCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargomaximumvo.SpecialCargoMaximumPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargomaximumvo.SpecialCargoMaximumRespVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargomaximumvo.SpecialCargoMaximumUpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;


import com.cmc.cloud.cmclink.doc.entity.SpecialCargoMaximumDO;
import com.cmc.cloud.cmclink.doc.convert.SpecialCargoMaximumConvert;
import com.cmc.cloud.cmclink.doc.service.special.SpecialCargoMaximumService;


/**
 * 单船特种货最大装载量限制维护前端接口Controller
 *
 * @author codegen
 */
@Tag(name = "管理后台 - 单船特种货最大装载量限制维护")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "/cargoMaximum")
public class SpecialCargoMaximumController {

    @Resource
    private SpecialCargoMaximumService specialCargoMaximumService;

    @Operation(summary = "创建单船特种货最大装载量限制维护")
    @PostMapping("/create")
    public CommonResult<Void> createSpecialCargoMaximum(@Valid @RequestBody SpecialCargoMaximumCreateReqVO createReqVO) {
        specialCargoMaximumService.createSpecialCargoMaximum(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新单船特种货最大装载量限制维护")
    @PostMapping("/update")
    public CommonResult<Void> updateSpecialCargoMaximum(@Valid @RequestBody SpecialCargoMaximumUpdateReqVO updateReqVO) {
        specialCargoMaximumService.updateSpecialCargoMaximum(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除单船特种货最大装载量限制维护")
    @PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Void> deleteSpecialCargoMaximum(@PathVariable("id") Long id) {
        specialCargoMaximumService.deleteSpecialCargoMaximum(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得单船特种货最大装载量限制维护")
    @GetMapping("/getById/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<SpecialCargoMaximumRespVO> getSpecialCargoMaximum(@PathVariable("id") Long id) {
        SpecialCargoMaximumDO specialCargoMaximum = specialCargoMaximumService.getSpecialCargoMaximum(id);
        return CommonResult.success(SpecialCargoMaximumConvert.INSTANCE.convert(specialCargoMaximum));
    }

    @Operation(summary = "获得单船特种货最大装载量限制维护列表")
    @GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    public CommonResult<List<SpecialCargoMaximumRespVO>> getSpecialCargoMaximumList(@RequestParam("ids") Collection<Long> ids) {
        List<SpecialCargoMaximumDO> list = specialCargoMaximumService.getSpecialCargoMaximumList(ids);
        return CommonResult.success(SpecialCargoMaximumConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得单船特种货最大装载量限制维护分页")
    @PostMapping("/page")
    @UseResponsePropertyAdvice
    public CommonResult<PageResult<SpecialCargoMaximumRespVO>> getSpecialCargoMaximumPage(@Valid @RequestBody SpecialCargoMaximumPageReqVO pageVO) {
        PageResult<SpecialCargoMaximumDO> pageResult = specialCargoMaximumService.getSpecialCargoMaximumPage(pageVO);
        List<SpecialCargoMaximumRespVO> results = SpecialCargoMaximumConvert.INSTANCE.convertList(pageResult.getList());
        return CommonResult.success(new PageResult<>(results, pageResult.getTotal()));
    }
}
